package com.we.utils.iplocation;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.IntStream;

/**
 * @Description:位置
 * @author:difeng
 * @date:2016年12月13日
 */
public class Location {

    public String country;

    public String area;

    @Override
    public String toString() {
        return "Location [country=" + country + ", area=" + area + "]";
    }

    public Map<String, String> toMap() {
        List<String> keys = Arrays.asList("land", "country", "country_english", "country_id", "international_code",
                "isp", "region", "city", "area", "region_id", "city_id", "area_id", "lat", "lng");
        List<String> values = Arrays.asList((country + "|" + area).split("\\|"));
        return IntStream.range(0, keys.size()).collect(HashMap::new,
                (m, i) -> m.put(keys.get(i), values.get(i).equals("*") ? "" : values.get(i)), (m1, m2) -> {});
    }

}
